$(document).ready(function(){
	$(".firstTree").click(function(){
		var id = $(this).attr("id");
		$("."+id).toggle();
		$.post("./model.php",{model:"App",item:"AddJson",module:id,uid:Math.random()},
			function(data){
				if(H.isnull(data)){
					var html = '无详情';
				}
				else{
					var json = $.parseJSON(data);
					var html = '<h3>模块名-'+id+'</h3><p>模块描述：<span class="desc">'+json['desc']+'</span></p>';
					html += '<p>创建时间：<span class="date">'+json['date']+'</span></p>';
					html += '<p>操作者IP地址：<span class="ip">'+json['ip']+'<span></p>';
					html += '<p>文件路径包括，<br>app：<span class="appUrl">'+json['appUrl']+'</span><br>view：<span class="viewUrl">'+json['viewUrl']+'</span><br>js：<span class="jsUrl">'+json['jsUrl']+'</span><br>css：<span class="cssUrl">'+json['cssUrl']+'</span></p>';
				}
				$("#showPage").html(html);
		});
	});
	$("#addApp").click(function(){
		$("#dialogAdd").dialog({ buttons: [
				{
					text: "确认",
					click: function() {
						var name = $('input[name="modelName"]').val();
						var desc = $('input[name="modelDesc"]').val();
						if(H.isnull(name) || name.length<3){
							$("#dialogAddTip").html('模块名不可为空，且长度大于三个字符');
							$('input[name="modelName"]').focus();
							return;
						}
						if(H.isnull(desc)){
							$("#dialogAddTip").html('模块描述不可为空！！');
							$('input[name="modelDesc"]').focus();
							return;
						}
						$.post("./model.php",{model:"App",item:"create",data:{name:name,desc:desc},uid:Math.random()},
							function(data){
								location.reload();
						});
					}
				}
			],
			"width":"350px"
		});
	});
	$(".delApp").click(function(){
		var val = H.getIdVal($(this));
		$.post("./model.php",{model:"App",item:"delete",module:val,uid:Math.random()},
			function(data){
				alert(data);
				location.reload();
				//$("#tips").html(data);
		});
		//alert(val);
	});
	$(".expApp").click(function(){
		var val = H.getIdVal($(this));
		$.post("./model.php",{model:"App",item:"export",module:val,uid:Math.random()},
			function(data){
		});
		//alert(val);
	});
	$(".close").click(function(){
		var val = H.getIdVal($(this));
		$("."+val).toggle();
	});
});